import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'eq-algorithm-list',
  templateUrl: './algorithm-list.component.html'
})
export class AlgorithmListComponent implements OnInit {
  title = 'algorithm-list';
  filter: any = 0;

  filterList: any[] = [
    {
      label: '全部',
      value: 1
    },

    {
      label: '系统默认策略',
      value: 2
    },

    {
      label: '次新趋势',
      value: 3
    },

    {
      label: '超短线',
      value: 4
    },

    {
      label: '回收站',
      value: 5
    }
  ]

  list: any[] = [
    {
      id: 1,
      title: '双均线策略',
      status: '未开始',
      typeText: '系统默认策略',
      type: 2,
      check: true,
      backtestCount: 3,
      buildCount: 2
    },

    {
      id: 2,
      title: '就干开板次新',
      status: '未开始',
      typeText: '次新趋势',
      type: 3,
      check: false,
      backtestCount: 3,
      buildCount: 2
    },

    {
      id: 3,
      title: '有五必有七, 满仓就是干',
      status: '未开始',
      typeText: '超短线',
      type: 4,
      check: false,
      backtestCount: 3,
      buildCount: 2
    },

    {
      id: 4,
      title: '招商伊利轮动',
      status: '未开始',
      typeText: '-',
      type: 1,
      check: false,
      backtestCount: 3,
      buildCount: 2
    },

    {
      id: 6,
      title: '赢了会所嫩模, 输了下海干活',
      status: '未开始',
      typeText: '超短线',
      type: 4,
      check: false,
      backtestCount: 0,
      buildCount: 0
    }
  ];

  queryList: any[] = []

  cacheAllList: any[];

  constructor() {}

  ngOnInit() {
    this.queryList = this.list;
  }

  ngOnFilterHandle(index: any) {
    console.log(index);
    this.filter = index;

    if (this.filter === 1) {
      this.queryList = this.list;
    } else {
      this.queryList = this.list.filter(item => {
        return item.type === this.filter;
      });
    }
  }

  ngOnCheckHandle(ref: any) {
    console.log(ref.index)
    console.log(ref.rowData)
    console.log(ref.innerHTML)
  }

  ngOnDeleteHandle(ref: any): void {
    console.log(ref.index)
    console.log(ref.rowData)
    console.log(ref.innerHTML)
    ref.destroy()
  }

  ngOnBuildHandle(ref: any): void {
    console.log(ref.index)
    console.log(ref.rowData)
    console.log(ref.innerHTML)
    ref.destroy()
  }

  ngOnBacktestHandle(ref: any): void {
    console.log(ref.index)
    console.log(ref.rowData)
    console.log(ref.innerHTML)
    ref.destroy()
  }
}
